package ticketManagement;

import java.io.Serializable;
import java.security.InvalidParameterException;

import transportManagement.Transport;

public class Ticket implements Serializable {
	private static final long serialVersionUID = -783656261067034164L;
	
	private String ticketId;
	private Transport transport;

	public Ticket() {
		
	}
	
	public Ticket(Transport transport) {
		this.transport = transport;
	}

	public Transport getTransport() {
		return transport;
	}

	public void setTransport(Transport corsa) {
		this.transport = corsa;
	}

	public String getTicketId() {
		return ticketId;
	}

	public void setTicketId(String ticketId) {
		this.ticketId = ticketId;
	}
	
	public double getPrize() throws InvalidParameterException {
		if (transport == null){
			throw new InvalidParameterException("Corsa is wrong!");
		}
		return transport.getSeatPrize();	
	}
	
	public boolean equals(Ticket biglietto) {
		return biglietto != null && this.ticketId.equalsIgnoreCase(biglietto.getTicketId());
	}
	
	public boolean equals(Object object) {
		return object != null && object instanceof Ticket && this.ticketId.equalsIgnoreCase(((Ticket)object).getTicketId());
	}

	public String toString() {
		return "Ticket[TicketId:" + this.getTicketId() + 
				";Transport:" + this.getTransport() + 
				"]";
	}
}
